import types from './types'
import axios from 'axios'
import Rest from '@/service/rest'

export default {
  /**
   * 获取列表
   */
  getPerms ({commit}, params) {
    let url = '/perms'
    return new Promise((resolve, reject) => {
      axios.get(url, {
        params
      })
      .then(res => {
        commit(types.SET_PERMS, res.data)
        resolve(res.data)
      })
      .catch(error => {
        Rest.errorHandler(error)
        reject(error)
      })
    })
  }
}
